package com.xique.api.bean.validation;

import com.xique.api.bean.request.ReceiveCouponRequest;
import com.xique.common.core.utils.StringUtils;
import com.xique.common.core.web.domain.AjaxResult;
import org.springframework.stereotype.Component;

/**
 * @author shd
 * @create 2022/1/12 15:05
 */
@Component
public class CouponValidation {

    public AjaxResult checkReceiveCouponRequest(ReceiveCouponRequest request) {
        if (StringUtils.isEmpty(request.getParkingSerial())) {
            return AjaxResult.error("请传入停车流水");
        }
        if (StringUtils.isEmpty(request.getCouponName())) {
            return AjaxResult.error("请传入优惠券名称");
        }
        if (StringUtils.isEmpty(request.getType())) {
            return AjaxResult.error("请传入优惠券类型");
        }
        if (StringUtils.isEmpty(request.getValue())) {
            return AjaxResult.error("请传入优惠金额");
        }
        if (StringUtils.isEmpty(request.getPlate())) {
            return AjaxResult.error("请传入车牌号");
        }
        if (StringUtils.isEmpty(request.getGrantSerial())) {
            return AjaxResult.error("请传入优惠券派发流水");
        }
        return AjaxResult.success();
    }
}
